#pragma once


/*
 * TLS client implementation using GnuTLS
 * Dependencies: bzbnet, GnuTLS
 */


#include "socket.h"


namespace bzbnet {


	constexpr unsigned int DEFAULT_TLS_PACKETSIZE = 512;


/*
 * Initializes te GnuTLS library and credentials structure.
 * TLSClient calls this function automatically.
 */
void initialize_tls();


/*
 * Destroys the GnuTLS library and credentials structure.
 */
void destroy_tls();


class TLSClient {
	private:
		TCPSocket socket;
		void* session_ptr;

	public:

		TLSClient();
		
		~TLSClient();
	
		void connect(std::string hostname, std::string service = "443");

		std::vector<char> recv(unsigned int packetsize = DEFAULT_TLS_PACKETSIZE);

		void send(std::string data);

		void send(std::vector<char> data);

		void close();

		bool is_open();

		int get_raw_fd();

};


}
